#encoding: utf-8
namespace :introduce do
  desc "introduce data auto"
  task create: :environment do
    if Introduce.description.chinese.blank?
      description = Introduce.new(content: '无', flag: 'description', language: 1)
      if description.save
        puts "公司简介简体中文创建成功"
      else
        puts "公司简介简体中文创建失败"
      end
    end

    if Introduce.description.english.blank?

      description = Introduce.new(content: 'nothing', flag: 'description', language: 2)
      if description.save
        puts "公司简介英文创建成功"
      else
        puts "公司简介英文创建失败"
      end
    end

    if Introduce.description.traditional.blank?

      description = Introduce.new(content: '憮', flag: 'description', language: 3)
      if description.save
        puts "公司简介繁体中文创建成功"
      else
        puts "公司简介繁体中文创建失败"
      end

    end

    if Introduce.service.chinese.blank?
      service = Introduce.create(content: '无', flag: 'service', language: 1)
      if service.save
        puts "服务介绍简体中文创建成功"
      else
        puts "服务介绍简体中文创建失败"
      end
    end

    if Introduce.service.english.blank?

      service = Introduce.new(content: 'nothing', flag: 'service', language: 2)
      if service.save
        puts "服务介绍英文创建成功"
      else
        puts "服务介绍英文创建失败"
      end
    end

    if Introduce.service.traditional.blank?

      service= Introduce.new(content: '憮', flag: 'service', language: 3)
      if service.save
        puts "服务介绍繁体中文创建成功"
      else
        puts "服务介绍繁体中文创建失败"
      end

    end

    if Introduce.customer.chinese.blank?
      customer = Introduce.create(content: '无', flag: 'customer', language: 1)
      if customer.save
        puts "客户案例简体中文创建成功"
      else
        puts "客户案例简体中文创建失败"
      end
    end

    if Introduce.customer.english.blank?

      customer = Introduce.new(content: 'nothing', flag: 'customer', language: 2)
      if customer.save
        puts "客户案例介绍英文创建成功"
      else
        puts "客户案例英文创建失败"
      end
    end

    if Introduce.customer.traditional.blank?

      customer = Introduce.new(content: '憮', flag: 'customer', language: 3)
      if customer.save
        puts "客户案例繁体中文创建成功"
      else
        puts "客户案例繁体中文创建失败"
      end
    end

    if Introduce.partner.chinese.blank?
      partner = Introduce.create(content: '无', flag: 'partner', language: 1)
      if partner.save
        puts "合作伙伴简体中文创建成功"
      else
        puts "合作伙伴简体中文创建失败"
      end
    end

    if Introduce.partner.english.blank?

      partner = Introduce.new(content: 'nothing', flag: 'partner', language: 2)
      if partner.save
        puts "合作伙伴英文创建成功"
      else
        puts "合作伙伴英文创建失败"
      end
    end

    if Introduce.partner.traditional.blank?

      partner = Introduce.new(content: '憮', flag: 'partner', language: 3)
      if partner.save
        puts "合作伙伴繁体中文创建成功"
      else
        puts "合作伙伴繁体中文创建失败"
      end
    end

  end
end
